package com.broada.apm.logic;

import java.util.Date;
import java.util.List;
import java.util.Set;

import com.broada.apm.entity.AreaPerformance;
import com.broada.apm.entity.PerformanceDetail;
import com.broada.apm.entity.PerformanceGroup;
import com.broada.apm.indicator.api.common.ApmDataIndicatorException;
import com.broada.apm.model.ApplicationSystem;
import com.broada.apm.model.PagingList;
import com.broada.apm.model.PerformanceView;

public interface PerformanceLogic {


	/**
	 * 查询时间段内系能信息
	 * 
	 * @param appIds
	 * @param agentIds
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	public List<PerformanceGroup> queryPerformance(String[] appIds, String[] agentIds, long startDate, long endDate,
			String size);

	/**
	 * 根据维度类型查询应用系能性能 Area较特殊 单独增加接口处理，见queryPerformanceByArea
	 * 
	 * @param appId
	 *          系统id
	 * @param dimensionType
	 *          维度类型
	 * @param perfTypes
	 *          性能指标类型数组
	 * @param startDate
	 *          开始时间
	 * @param endDate
	 *          结束时间
	 * @return
	 */
	public List<PerformanceView> queryPerformanceByDimensionType(String appId, String dimensionType, int top,
			String orderBy, long startDate, long endDate, String panelId);

	/**
	 * 根据地域维度查询应用系能性能
	 * 
	 * @param appId
	 *          系统id
	 * @param perfTypes
	 *          性能指标类型数组
	 * @param startDate
	 *          开始时间
	 * @param endDate
	 *          结束时间
	 * @return
	 */
	public AreaPerformance queryPerformanceByArea(String appId, String sortField, long startDate, long endDate);

	/**
	 * 查询关键交易详情
	 * 
	 * @param appId
	 * @param resId
	 * @param top
	 *          关键交易详情页面错误码显示前top条
	 * @return
	 */
	public PerformanceDetail queryDetailsPerformanceByKeyTrade(String appId, String resId, Date startDate, Date endDate);

	/**
	 * 实时查询交易详细信息
	 * 
	 * @param appId
	 * @param resId
	 * @param lastDate
	 * @return
	 */
	public PerformanceDetail queryDetailsPerformanceByLastDate(String appId, String resId, Date lastDate);

	/**
	 * 按连接查询接入性能
	 * 
	 * @param appId
	 * @param nodeId
	 * @param startDate
	 * @param endDate
	 * @param pageIndex
	 * @param pageSize
	 * @return
	 */
	public PagingList<PerformanceView> queryPerformanceByConnection(String appId, String nodeId, Date startDate,
			Date endDate, int pageIndex, int pageSize);
	/**
	 * 最终用户体验
	 * 
	 * @param appId
	 * @param protoCode
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	public List<PerformanceView> queryPerformanceByPage(String appId, int top, String sortField, long startDate,
			long endDate);

	/**
	 * 最终用户体验--具体页面实时数据
	 * 
	 * @param appId
	 * @param protoCode
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	public List<PerformanceView> queryPerformanceByPageId(String appId, String resourceId, String field,
			String size, Date startDate, Date endDate);
	/**
	 * @param panelId 
	 * @param desc 
	 * @param orderBy 
	 * 
	  * @Title: queryPerformanceSubTotal
	  * @Description: 
	  * @param @param appId
	  * @param @param type
	  * @param @param targetIds
	  * @param @param startDate
	  * @param @param endDate
	  * @param @return
	  * @return List<PerformanceView>
	  * @throws
	 */
	public List<PerformanceView> queryPerformanceSubTotal(String appId, String type, String targetIds, Date startDate, Date endDate, String orderBy, boolean desc, String panelId);

	public List<PerformanceView> queryPerformance(List<String> appIds, String nodeId, String keyTradeId, String typeName, String channelName, long startDate, long endDate, Integer last, String field);
	
	public PerformanceDetail queryDetailsPerformanceByTransaction(String appId, String tradeTypeName, Date date, Date date2, String agentId);

	/**
	 * 某段时间内各个应用系统的性能
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	public List<PerformanceView> queryAppPerfs(Set<String> applicationId, Date startDate, Date endDate);

	/**
	 * 各个时间段内各个应用系统的性能
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	public List<PerformanceView> queryAppTermsPerfs(Date startDate, Date endDate);

	public List<PerformanceView> queryThisDayData(ApplicationSystem application, List<String> appId, long startDate, long endDate) throws ApmDataIndicatorException;
}
